using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using NCS.Module.CMS.Library;
using NCS.Library.Utilities;
using NCS.Module.CMS.Library.Definitions;
using NCS.Library;
using NCS.Module.CMS.Library.Distributions;
using NCS.Library.Components.Partner;
using NCS.Module.CMS.Library.Zones;
using NCS.Library.Components.Modules;

namespace NCS.Module.CMS.Web.HomePage
{
    public partial class TinNhanh : CMSWebControl
    {
        private int zoneid;
        protected void Page_Load(object sender, EventArgs e)
        {
            zoneid = ConvertUtility.ToInt32(Portal[Constants.CMS_QuickNews + AppEnv.GetLanguage()]);
            ZoneInfo info = ZoneController.GetZone(zoneid);

            hplCaption.Text = info.Zone_Name;
            hplCaption.NavigateUrl = BuildUrlByZone(zoneid, info.Portal_TabControlID);

            DataTable tbl = DistributionController.GetDistributedContents(zoneid, 10, -1);
            if (tbl != null && tbl.Rows.Count > 0)
            {
                this.rpt.DataSource = tbl;
                this.rpt.DataBind();
            }
        }

        protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView currow = (DataRowView)e.Item.DataItem;
                HyperLink hplTitle = (HyperLink)e.Item.FindControl("hplTitle");

                hplTitle.Text = ConvertUtility.ToString(currow["Content_Headline"]);

                string tooltip = MiscUtility.ToolTip(ConvertUtility.ToString(currow["Content_Headline"]), ConvertUtility.ToString(currow["Content_SubTitle"]), ConvertUtility.ToString(currow["Content_Avatar"]), ConvertUtility.ToString(currow["Content_Teaser"]), ConvertUtility.ToString(currow["Content_Alias"]), ConvertUtility.ToDateTime(currow["Distribution_CreateDate"]));
                //hplTitle.Attributes.Add("onmouseover", "showtip('" + tooltip + "','322','#EBF3FB')");
                //hplTitle.Attributes.Add("onmouseout", "hidetip()");

                //hplTitle.NavigateUrl = BuildUrlByDistId((int)currow["Distribution_ID"], zoneid);
                hplTitle.NavigateUrl = BuildUrlByDistId((int)currow["Content_ID"], zoneid);
            }
        }
    }
}